<?php defined('API') or exit();?>
<div style="border:1px solid #ddd">
        <div style="background:#f5f5f5;padding:20px;position:relative">
            <h4>添加接口<span style="font-size:12px;padding-left:20px;color:#a94442">注:"此色"边框为必填项</span></h4>
            <div style="margin-left:20px;">
                <form action="?act=api&tag=<?php echo $_GET['tag']?>&type=do&op=add" method="post">
                    <h5>基本信息</h5>
                    <div class="form-group has-error">
                        <div class="input-group">
                            <div class="input-group-addon">接口编号</div>
                            <input type="text" class="form-control" name="num" placeholder="接口编号" required="required">
                        </div>
                    </div>
                    <div class="form-group has-error">
                        <div class="input-group">
                            <div class="input-group-addon">接口名称</div>
                            <input type="text" class="form-control" name="name" placeholder="接口名称" required="required">
                        </div>
                    </div>
                    <div class="form-group has-error">
                        <div class="input-group">
                            <div class="input-group-addon">请求地址</div>
                            <input type="text" class="form-control" name="url" placeholder="请求地址" required="required">
                        </div>
                    </div>
                    <div class="form-group">
                        <textarea name="des" class="form-control" placeholder="描述"></textarea>
                    </div>
                    <div class="form-group" required="required">
                        <select class="form-control" name="type">
                            <option value="POST">POST</option>
                            <option value="GET">GET</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <h5>请求参数</h5>
                        <table class="table" id="request_table">
                            <thead>
                            <tr>
                                <th class="col-md-2">参数名</th>
                                <th class="col-md-2">属性</th>
                                <th class="col-md-1">类型</th>
                                <th class="col-md-1">必传</th>
                                <th class="col-md-2">缺省值</th>
                                <th class="col-md-2">描述</th>
                                <th class="col-md-2">
                                    <button type="button" class="btn btn-success" onclick="add()">新增</button>
                                    <button type="button" class="btn btn-danger" onclick="$('#request_table').remove()">删除</button>
                                </th>
                            </tr>
                            </thead>
                            <tbody id="parameter">
                            <tr>
                                <td class="form-group has-error">
                                    <input type="text" class="form-control" name="p[name][]" placeholder="参数名" required="required">
                                </td>
                                <td class="form-group has-error">
                                    <input type="text" class="form-control" name="p[prp][]" placeholder="属性" required="required">
                                </td>
                                <td>
                                    <select class="form-control" name="p[type][]">
                                        <option value="string">string</option>
                                        <option value="int">int</option>
                                        <option value="long">long</option>
                                        <option value="float">float</option>
                                        <option value="double">double</option>
                                        <option value="file">file</option>
                                    </select>
                                </td>
                                <td>
                                    <select class="form-control" name="p[must][]">
                                        <option value="Y">Y</option>
                                        <option value="N">N</option>
                                    </select>
                                </td>
                                <td><input type="text" class="form-control" name="p[default][]" placeholder="缺省值"></td>
                                <td><textarea name="p[des][]" rows="1" class="form-control" placeholder="描述"></textarea></td>
                                <td><button type="button" class="btn btn-danger" onclick="del(this)">删除</button></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <hr style="border-bottom: 2px solid black;font-weight: bold;">
                   
                   <div class="form-group">
                        <h5>返回结果</h5>
                        <input type="text" id="newTableName" placeholder="子表格名称" style="width: 100px">
                        <button type="button" class="btn btn-success" onclick="add_new_table()">新增表格</button>
                       
                        <table class="table" id="table_default">
                        	<thead>
                            <tr>
                                <th class="col-md-2">参数名</th>
                                <th class="col-md-2">属性</th>
                                <th class="col-md-2">类型</th>
                                <th class="col-md-2">缺省值</th>
                                <th class="col-md-2">描述</th>
                                <th class="col-md-2">
                                    <button type="button" class="btn btn-success" onclick="add_result('default')">新增</button>
                                </th>
                            </tr>
                            </thead>
                            <tbody id="result_param">
	                            <tr>
	                                <td class="form-group has-error">
	                                    <input type="text" class="form-control" name="r[default][name][]" placeholder="参数名" value="status" required="required">
	                                </td>
	                                <td class="form-group has-error">
	                                    <input type="text" class="form-control" name="r[default][prp][]" placeholder="属性" value="状态码" required="required">
	                                </td>
	                                <td>
	                                    <select class="form-control" name="r[default][type][]">
	                                        <option value="string">string</option>
	                                        <option value="int">int</option>
	                                        <option value="long">long</option>
	                                        <option value="list">list</option>
	                                        <option value="array">array</option>
	                                        <option value="object">object</option>
	                                        <option value="float">float</option>
	                                        <option value="double">double</option>
	                                        <option value="other">other</option>
	                                    </select>
	                                </td>
	                                <td><input type="text" class="form-control" name="r[default][default][]" placeholder="缺省值" value="0"></td>
	                                <td><textarea name="r[default][des][]" rows="1" class="form-control" placeholder="描述">0获取成功;1 接口错误;2 空列表</textarea></td>
	                                <td><button type="button" class="btn btn-danger" onclick="del(this)">删除</button></td>
	                            </tr>
	                            <tr>
	                                <td class="form-group has-error">
	                                    <input type="text" class="form-control" name="r[default][name][]" placeholder="参数名" value="errcode" required="required">
	                                </td>
	                                <td class="form-group has-error">
	                                    <input type="text" class="form-control" name="r[default][prp][]" placeholder="属性" value="错误编码" required="required">
	                                </td>
	                                <td>
	                                    <select class="form-control" name="r[default][type][]">
	                                        <option value="string">string</option>
	                                        <option value="int">int</option>
	                                        <option value="long">long</option>
	                                        <option value="list">list</option>
	                                        <option value="array">array</option>
	                                        <option value="object">object</option>
	                                        <option value="float">float</option>
	                                        <option value="double">double</option>
	                                        <option value="other">other</option>
	                                    </select>
	                                </td>
	                                <td><input type="text" class="form-control" name="r[default][default][]" placeholder="缺省值"></td>
	                                <td><textarea name="r[default][des][]" rows="1" class="form-control" placeholder="描述">错误编码</textarea></td>
	                                <td><button type="button" class="btn btn-danger" onclick="del(this)">删除</button></td>
	                            </tr>
	                             <tr>
	                                <td class="form-group has-error">
	                                    <input type="text" class="form-control" name="r[default][name][]" placeholder="参数名" value="errmsg" required="required">
	                                </td>
	                                <td class="form-group has-error">
	                                    <input type="text" class="form-control" name="r[default][prp][]" placeholder="属性" value="错误描述" required="required">
	                                </td>
	                                <td>
	                                    <select class="form-control" name="r[default][type][]">
	                                        <option value="string">string</option>
	                                        <option value="int">int</option>
	                                        <option value="long">long</option>
	                                        <option value="list">list</option>
	                                        <option value="array">array</option>
	                                        <option value="object">object</option>
	                                        <option value="float">float</option>
	                                        <option value="double">double</option>
	                                        <option value="other">other</option>
	                                    </select>
	                                </td>
	                                <td><input type="text" class="form-control" name="r[default][default][]" placeholder="缺省值"></td>
	                                <td><textarea name="r[default][des][]" rows="1" class="form-control" placeholder="描述">失败状态</textarea></td>
	                                <td><button type="button" class="btn btn-danger" onclick="del(this)">删除</button></td>
	                            </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <div class="form-group" id="lastResult">
                    <textarea name="re" rows="3" class="form-control" placeholder="返回结果"></textarea>
                    </div>
                    <div class="form-group">
                        <h5>备注</h5>
                        <textarea name="memo" rows="3" class="form-control" placeholder="备注"></textarea>
                    </div>
                    <div class="form-group">
                        <h5>状态</h5>
                        <select name="status" class="form-control">
                        	<option value="0">未完成</option>
                        	<option value="1">完成</option>
                        	<option value="2">作废</option>
                        </select>
                    </div>
                    <button class="btn btn-success">Submit</button>
                </form>
            </div>
        </div>
    </div>
    <script src="./MinPHP/res/api.js"></script>
